<template>
  <div class="big_vontainer">
    <div class="clo_container">
      <span class="iconfont iconicon-test"></span>
    </div>
    <div class="logo_container">
      <span class="iconfont iconnew"></span>
    </div>
    <!--注册框-->
    <myinput
      @getval="setusername"
      msg="输入注册用户名"
      type="text"
      :proof="/^\d{3,9}$/"
      errmsg="请输入正确用户名"
    ></myinput>
    <myinput
      @getval="setnickname"
      msg="输入昵称"
      type="text"
      :proof="/^[A-Za-z0-9]{4,40}$/"
      errmsg="昵称输入不正确请重新输入"
    >
    </myinput>
    <myinput
      @getval="setpassword"
      msg="输入注册密码"
      type="password"
      :proof="/^\d{3,9}$/"
      errmsg="请输入6到9位密码"
    ></myinput>
    <mybtn msg="注册" @click.native="axsend"></mybtn>
  </div>
</template>

<script>
import myinput from "../components/myinput";
import mybtn from "../components/mybtn";
export default {
  components: {
    myinput,
    mybtn,
  },
  data() {
    return {
      username: "",
      password: "",
      nickname: "",
    };
  },
  methods: {
    setusername(val) {
      this.username = val;
    },
    setnickname(val) {
      this.nickname = val;
    },
    setpassword(val) {
      this.password = val;
    },
    axsend() {
      this.$axios({
        method: "post",
        url: "/register",
        data: {
          username: this.username,
          password: this.password,
          nickname: this.nickname,
        },
      }).then((res) => {
        if (res.data.message === "注册成功") {
          this.$toast(res.data.message);
          setTimeout(() => {
            this.$router.push("/login");
          }, 1000);
        }
      });
    },
  },
};
</script>

<style lang="less">
.big_vontainer {
  padding: 16 / 360 * 100vw;
  background-color: #f2f2f2;
  min-height: 100vh;
}
.iconicon-test {
  font-size: 27 / 360 * 100vw;
}
.logo_container {
  text-align: center;
  .iconnew {
    font-size: 126 / 360 * 100vw;
    color: #cc3300;
  }
}
</style>